/**
 * <b>项目名：</b>hclv-web<br/>  
 * <b>包名：</b>com.flea.hclv.service.impl<br/>  
 * <b>文件名：</b>HAddressServiceImpl.java<br/>  
 * <b>版本信息：</b>1.0<br/>  
 * <b>日期：</b>2018年9月16日 上午2:02:57<br/>  
 * <b>COPYRIGHT 2010-2012 ALL RIGHTS RESERVED 虫子科技</b>-版权所有<br/>
 */
package com.flea.hclv.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.flea.hclv.model.dao.HAddressMapper;
import com.flea.hclv.model.entity.HAddress;
import com.flea.hclv.service.HAddressService;
import com.flea.system.utils.FleaStringUtils;


/**
 * @description
 * @createTime 2018年9月16日 上午2:02:57
 * @modifyTime 
 * @author myflea@163.com
 * @version 1.0
 */
@Service("addressService")
public class HAddressServiceImpl implements HAddressService {
	@Autowired
	private HAddressMapper addressMapper;

	@Override
	public boolean saveOrUpdateByRlealUuid(String relationUuid, HAddress entity,String userId) {
		HAddress oldHaddress = addressMapper.findByRelattionUuid(relationUuid);
		int result = 0;
		entity.setModifyUser(userId);
		if(null==oldHaddress){
			String id = FleaStringUtils.getGenerateUUID();
			entity.setId(id);
			entity.setCreateUser(userId);
			result = addressMapper.insertSelective(entity);
		}else{
			result =  addressMapper.updateByPrimaryKeySelective(entity);
		}
		return result>0;
	}

	@Override
	public boolean deleteByRaltionUuid(String relationUuid) {
		return false;
	}

	@Override
	public HAddress findById(String addressId) {
		HAddress result = addressMapper.selectByPrimaryKey(addressId);
		return result;
	}

	@Override
	public HAddress findByHotelId(String hotelId) {
		HAddress result = addressMapper.findByRelattionUuid(hotelId);
		return result;
	}


}
